﻿@{
    
    var menus = new[]
                {
                  // new { LinkText="Home", ActionName="Index",ControllerName="Home",Roles="All" },
                  // new { LinkText="Administration", ActionName="Index",ControllerName="Administration",Roles="Administrator" },
                   new { LinkText="Administration", ActionName="Index",ControllerName="Administration",Roles="All" },
                   new { LinkText="Ordering", ActionName="Index",ControllerName="Ordering",Roles="All" },
                   new { LinkText="Item Management", ActionName="Index",ControllerName="Item",Roles="All" },
                   new { LinkText="Merchandise", ActionName="Index",ControllerName="Merchandise",Roles="All" }
                };
}
<div class="menu">
<ul>
@if (HttpContext.Current.User.Identity.IsAuthenticated)
{
    String[] roles = Roles.GetRolesForUser();
    var links = from item in menus
                where item.Roles.Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                .Any(x => roles.Contains(x) || x == "All")
                select item;
    foreach (var link in links)
    {
        @: <li> @Html.ActionLink(link.LinkText, link.ActionName,link.ControllerName)</li>
    }
}
else{
    var links = from item in menus
                where item.Roles.Split(new String[]{","},StringSplitOptions.RemoveEmptyEntries)
                .Any(x=>new String[]{"All","Anonymous"}.Contains(x))
                select item;
     foreach ( var link in links){
         @: <li> @Html.ActionLink(link.LinkText, link.ActionName, link.ControllerName)</li>
     }
}
</ul>
    </div> 